home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
answrbok
/
5_5.lha
/
5_5
/
5_5c3_W.c
< prev
next >
Wrap
Text File
|
1993-08-08
|
1KB
|
57 lines
* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
* The C++ Answer Book */
* Tony Hansen */
* All rights reserved. */
/ initialize for the WE32100
/ (nothing to do)
oid setup()
/ finish things up
oid finishup(stackalloc &stacktop)
cout << "\tMOVW ";
stacktop.print(cout) << ", result\n";
/ print out a binary operator followed by the
/ source and destination
tatic void binop(const tree *head,
stackalloc &curloc, const intalloc *cursp)
assemblyprint(head->left, curloc, cursp);
stackalloc newloc(cursp);
assemblyprint(head->right, newloc, cursp);
switch (head->type)
{
case PLUS: cout << "\tADDW2 "; break;
case MUL: cout << "\tMULW2 "; break;
case DIV: cout << "\tDIVW2 "; break;
case MINUS: cout << "\tSUBW2 "; break;
}
newloc.print(cout) << ", ";
curloc.print(cout) << "\n";
/ print out a negate operator followed
/ by the destination
tatic void negop(const tree *head,
stackalloc &curloc, const intalloc *cursp)
stackalloc newloc(cursp);
assemblyprint(head->left, newloc, cursp);
cout << "\tMNEGW2 ";
newloc.print(cout) << ", ";
curloc.print(cout) << "\n";
/ store a number node at the current location
tatic void svnumber(tree* head, stackalloc &curloc)
cout << "\tMOVW &" << head->value << ", ";
curloc.print(cout) << "\n";